<?php

class StandardInnerConfig{

    private $mime;
    private $acceptMethod = array();
    private $rejectMethod = array();
    private $params = array();

    public function conditionsMet(){
        if (!(count($this->acceptMethod) == 0 || in_array($_SERVER['REQUEST_METHOD'],$this->acceptMethod)) && !in_array($_SERVER['REQUEST_METHOD'],$this->rejectMethod))//Method destinction
            return false;
        foreach ($this->params as $key => $val){
            if (!array_key_exists($key,$_REQUEST) || ($val !== null && $val != $_REQUEST[$key])){
                return false;
            }
        }
        return true;
    }

    public function setMime($mime){
        $this->mime = $mime;
        return $this;
    }

    public function addAcceptableMethod($method){
        $this->acceptMethod[$method] = $method;
        return $this;
    }

    public function removeAcceptableMethod($method){
        if (array_key_exists($method,$this->acceptMethod)){
            unset($this->acceptMethod[$method]);
        }
        return $this;
    }

    public function addUnacceptableMethod($method){
        $this->unacceptMethod[$method] = $method;
        return $this;
    }

    public function removeUnacceptableMethod($method){
        if (array_key_exists($method,$this->unacceptMethod)){
            unset($this->unacceptMethod[$method]);
        }
        return $this;
    }

    public function run(){
        if ($this->mime !== null){
            header('Content-Type: '.$this->mime);
        }
    }

    public function withParam($key,$value=null){
        $this->params[$key] = $value;
        return $this;
    }

}

?>